package com.forlgb.powercloud.authorization.controller;


import com.forlgb.powercloud.authorization.entity.SysUser;
import com.forlgb.powercloud.authorization.service.impl.SysUserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lyk
 * @since 2021-05-28
 */
@RestController
@RequestMapping("/sys-user")
public class SysUserController {
    @Autowired
    private SysUserServiceImpl sysUserService;

    @PostMapping(value = "/addSysUser")
    public boolean test(String name, String password) {
        SysUser sysUser = new SysUser();
        sysUser.setUsername(name);
        sysUser.setPassword(new BCryptPasswordEncoder().encode(password));
        return sysUserService.saveOrUpdate(sysUser);
    }
}
